home *** CD-ROM | disk | FTP | other *** search
/ Computer Inter@ctive 17 / Computer Interactive cdrom 17 - gen 99.iso / ZDNETIT / CONTENT / WEBDATA.ZIP / winstall.pl < prev   
Encoding:
Text File  |  1998-07-24  |  6.2 KB  |  241 lines

  1. print "
  2. Welcome to the installer program for webdata, the easiest database program 
  3. for the world wide web.  The installer will ask you a few questions about
  4. your server.  You should complete the worksheet included in the readme.html
  5. document before continuing. By pressing \'y\' you are agreeing to absolve the
  6. authors of all liability related to use of this program.
  7.  
  8. Would you like to continue? [y,n]
  9. ";
  10. $_ = <STDIN>;
  11. if (/^n/i) {exit;}; 
  12.  
  13. print "
  14. Choose a short name for this database:
  15. ";
  16. $dbname=<STDIN>;
  17. chop($dbname);
  18.  
  19. $webdata = "webdata_$dbname".".pl";
  20. $userform = $dbname."_form.html";
  21. $admin = $dbname."_admin.html";
  22. $memberentry = $dbname."_members.html";
  23. $webdatafields = $dbname."_fields.log";
  24. $datalog = $dbname."_data.log";
  25. $memberfile = $dbname."_members.log";
  26. $reportpref= $dbname."_report.log";
  27.  
  28. $dirname="/cgi-bin/$webdata";
  29. print "\nPlease enter the path to the /cgi-bin/ directory:\n";
  30. $pathToCgiBin = <STDIN> ;
  31. chop($pathToCgiBin);
  32.  
  33. print "\n";
  34. print "\nWhat is the URL of your homepage?
  35. (start with http://)\n";
  36. $homepage = <STDIN>;
  37.  
  38. $password=" ";
  39. until ($password eq $second) {
  40.     if ($password ne " ") {print "Not a match, try again.\n\n"};
  41.     print "\nWhat would you like you password to be?\n";
  42.     $password = <STDIN>;
  43.     print "\nPlease enter your password again.\n";
  44.     $second = <STDIN>;
  45. };
  46.  
  47. print "\n";
  48. print "Would you like visitors to be able to ADD entries to the database? (y/n)\n";
  49. $useradd = <STDIN>;
  50. chop ($useradd);
  51. $_=$useradd;
  52. if (/^y/i) {$useradd = "true"} else {$useradd = "false"};
  53.  
  54. print "\n";
  55. print "Would you like visitors to be able to SEARCH the database? (y/n)\n";
  56. $usersearch = <STDIN>;
  57. chop ($usersearch);
  58. $_=$usersearch;
  59. if (/^y/i) {$usersearch = "true"} else {$usersearch = "false"};
  60.  
  61.  
  62. open(CGIREAD,"<webdata.cgi");
  63. @lines = <CGIREAD>;
  64. close CGIREAD;
  65. $now=time();
  66. $path = `chdir`;
  67. chop($path);
  68. $idcode=substr($now,-4);
  69.  
  70. chop($homepage);
  71. chop($password);
  72.  
  73. $lines[0]="\#\n";
  74. $lines[7]="\$homepage=\"$homepage\"\;\n";
  75. $lines[8]="\$password=\"$password\"\;\n";
  76. $lines[9]="\$cgilocation=\"$webdata\"\;\n";
  77. $lines[10]="\$logfile=\'$path\\$datalog\'\;\n";
  78. $lines[11]="\$fieldnames=\'$path\\$webdatafields\'\;\n";
  79. $lines[12]="\$members=\'$path\\$memberfile\'\;\n";
  80. $lines[13]="\$reportdata=\'$path/$reportpref\'\;\n";
  81. $lines[14]="\$code=\'$idcode\'\;\n";
  82.  
  83. foreach (@lines) {
  84.     if ((/<!--FLAG1-->/)&&($useradd eq "false")) {$_="<!--FLAG1-->\n"};
  85.     if ((/<!--FLAG2-->/)&&($useradd eq "true")) {$_="#<!--FLAG2-->\n"};
  86.     if ((/<!--FLAG3-->/)&&($usersearch eq "false")) {$_="<!--FLAG3-->\n"};
  87.     if ((/<!--FLAG4-->/)&&($usersearch eq "true")) {$_="#<!--FLAG4-->\n"};
  88.     if (/<!--FLAG5-->/) {$_="\$key=$now\; #<!--FLAG5-->\n"};
  89. };
  90. open(DATA,">$logfile");
  91. print DATA ("111::Delete Me\n");
  92. close DATA;
  93.  
  94. open(CGIWRITE,">$webdata");
  95. print CGIWRITE (@lines);
  96. close CGIWRITE;
  97.  
  98. print "\n
  99. The Installer will help you define your list of fields.
  100. Fields are the attributes you wish to record about each entry,
  101. for example, FirstName, LastName, Color, Make, Model,  EntryDate, 
  102. PartNumber, etc.
  103.  
  104. Press [ENTER] when you are finished entering fields. If you make a mistake,
  105. press [ENTER] and choose No when asked if you are satisfied with the list.
  106.  
  107. ";
  108.  
  109. $tryagain="true";
  110. while ($tryagain eq "true") {
  111.     $time = time();
  112.     @fields = ("webdata$time\n");
  113.     print "Enter a field name: ";
  114.     $field = <STDIN>;
  115.     push(@fields,$field);
  116.     $morefields="true";
  117.     while ($morefields eq "true") {
  118.         print "Enter another field name: ";
  119.         $field  = <STDIN> ;
  120.         push(@fields,$field);
  121.         $_=$field;
  122.         if (/./) {$morefields = "true"} else {$morefields = "false"};
  123.     };
  124.     print "\n";
  125.     pop(@fields);
  126.     foreach $field (@fields) {
  127.         if (substr($field,0,7) ne 'webdata') {print "$field";};
  128.     };
  129.  
  130.     print "\nAre you satisfied with the field list? (y/n)
  131.     [Type \'y\' to keep the list, \'n\' to enter the fields again]";
  132.     $tryagain = <STDIN>;
  133.     $_=$tryagain;
  134.     if (/^y/i) {$tryagain = "false"} else {$tryagain = "true"};
  135. }; 
  136.  
  137. foreach (@fields) {
  138. chop($_);
  139. $_=$_."::text:20\n";
  140. };
  141. open(FIELDLIST,">$webdatafields");
  142. print FIELDLIST (@fields);
  143. close FIELDLIST;
  144.  
  145. $rc=@fields;
  146. for($i=0;$i<$rc-1;$i++) {
  147. $row.="$i:";
  148. };
  149. chop($row);
  150. open(REPORT,">$reportpref");
  151. print REPORT ("BEIGE\n\n$row\n0\n0\n15\n0\n\n1\n");
  152. close REPORT;
  153.  
  154. open(FIELDS,"<$webdatafields");
  155. @fields = <FIELDS>;
  156. close FIELDS;
  157.  
  158. open(FORM,">$userform");
  159. $loc=$dirname."?cgifunction=user";
  160. print FORM ("
  161. <script language=\"javascript\">
  162. location.replace(\'$loc\')\;
  163. </script>
  164. ");
  165. close FORM;
  166.  
  167. open (ADMIN,">$admin");
  168. print ADMIN ("
  169. <HTML>
  170. <HEAD>
  171. <TITLE> Web Data Administration Password </TITLE>
  172. </HEAD>
  173.  
  174. <BODY BGCOLOR=BEIGE onLoad=\"document.form1.password.focus()\">
  175. <H1 ALIGN=CENTER>
  176. YOU MUST HAVE A PASSWORD TO ENTER THE ADMINISTRATION SITE
  177. </H1>
  178.  
  179. Enter password here:<BR>
  180. <FORM NAME=\"form1\" ACTION=\"$dirname\" METHOD=\"POST\">
  181. <INPUT TYPE=PASSWORD NAME=\"password\">
  182. <INPUT TYPE=HIDDEN NAME=\"cgifunction\" VALUE=\"admin\">
  183. <INPUT TYPE=SUBMIT VALUE=\"Enter\">
  184. </FORM>
  185.  
  186. </BODY>
  187. </HTML>
  188.  
  189. ");
  190. close ADMIN;
  191.  
  192. open (MEMBERPAGE,">$memberentry");
  193. print MEMBERPAGE ("
  194. <HTML>
  195. <HEAD>
  196. <TITLE> Web Data Member Password </TITLE>
  197. </HEAD>
  198.  
  199. <BODY BGCOLOR=BEIGE onLoad=\"document.form1.username.focus()\">
  200. <H1 ALIGN=CENTER>
  201. MEMBERS ENTRY PAGE.<BR>
  202. </H1>
  203.  
  204. <TABLE BORDER=0>
  205. <FORM NAME=\"form1\" ACTION=\"$dirname\" METHOD=\"POST\">
  206. <TR><TD><B>User Name</B><TD><INPUT TYPE=TEXT NAME=\"username\" SIZE=20><BR>
  207. <TR><TD><B>Password</B><TD><INPUT TYPE=PASSWORD NAME=\"password\" SIZE=20><BR>
  208. </TABLE>
  209. <INPUT TYPE=SUBMIT NAME=\"cgifunction\" VALUE=\"memberpage\">
  210. </FORM> 
  211. </BODY>
  212. </HTML>
  213.  
  214. ");
  215. close MEMBERPAGE;
  216.  
  217.  
  218. `copy $webdata "$pathToCgiBin"`;
  219.  
  220. open(BACKDOOR,">index.htm");
  221. print BACKDOOR ("<script>location.replace(\'$userform\')</script>");
  222. close BACKDOOR;
  223.  
  224. print "
  225. Two pages have been created for your convenience in the
  226. current directory ($path).
  227.  
  228. Guests should be linked to $userform to search your database
  229.  
  230. Administrators should go to $admin to add, modify, and remove records,
  231. import and export, modify fields, and add members.
  232.  
  233. Members with accounts can go to $memberentry to add and modify only
  234. their own records.
  235.  
  236. If you have difficulty, please read the troubleshooting page at
  237. http://www.webteacher.com/perltour/testhelp.htm
  238.  
  239. ";
  240.  
  241.